# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: web_socket.py
Author: kij
Create Date: 2021/2/25
-------------------------------------------------
"""
import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("192.168.1.27", 8002))  # windows 的ip地址 我有两台电脑
sock.listen(5)  # 支持5个链接等待

print(type(sock))
while True:
	# 等待客户端来连接
	conn, addr = sock.accept()
	print(type(conn))
	print(addr)
	# 等待链接着放消息（阻塞）
	client_data = conn.recv(1024)
	print(client_data.decode('utf-8'))
	# 给客户端发消息
	conn.sendall('hello world'.encode('utf-8'))
	conn.close()

sock.close()

